var b_lang;//=1，点击状态按钮
var SortJson = [];
var app_url=location.origin;
var EDITMODE=false; 
//日期格式化
var calendarDateFormat = myApp.calendar({
	input: '#eupdatetime',
    monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});
var calendarDateFormat = myApp.calendar({
	input: '#supdatetime',
    monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});
var calendarDateFormat = myApp.calendar({
	input: '#ecreatetime',
    monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});
var calendarDateFormat = myApp.calendar({
	input: '#screatetime',
    monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});
var calendarDateFormat = myApp.calendar({
	input: '#_arrivalTime',
    monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});
var calendarDateFormat = myApp.calendar({
	input: '#arrivalTime',
    monthNames: ['01'+_(''+_('月')), '02'+_('月'), '03'+_('月'), '04'+_('月'), '05'+_('月'), '06'+_('月'), '07'+_('月'), '08'+_('月') , '09'+_('月') , '10'+_('月'), '11'+_('月'), '12'+_('月')],
    dayNamesShort: [_('日'), _('一'), _('二'), _('三'), _('四'), _('五'), _('六')],
    closeOnSelect:true,
});

(function(){
	var apply = {
		init: function(){
			this.LoadData();
			this.bindEvents();
		},
		bindEvents:function(){
			var self = this;
			 //跳转页面
             $("#navMenu a").on("click",function(){
            	var link_url=$(this).attr("data-href");
            	if(APP){
            		var appJson={};
           			appJson.title=$(this).attr("data-title");
           			appJson.url=app_url+link_url;	
           			YiYi_APP.showNewPage(JSON.stringify(appJson));
            	}else{
            		location.href = link_url;
            	}
            });
			//点击行展开详情
			$("#stock_body").on("click", "tr td", function () {
			    var td_input = $(this).index();
			     if (td_input == 0 || td_input==7 || td_input==8) {
			        //勾选框不展开详情
			    } else {
			        $(this).parent("tr").next(".stock_detail").slideToggle(0);
			    }
			});
			$("#detail tbody").on("click", "tr td", function () {
			    $(this).parent("tr").next(".stock_detail").slideToggle(0);
			});
			
			//点击筛选按钮
			$("#show_term_btn").on("click", function () {
				myApp.popup(".user_filter_box");
			});
			//确定筛选
			$("#confirm_btn").on("click",function(){
				self.LoadData();//获取数据列表
				myApp.closeModal(".user_filter_box");
			});
			//状态筛选
			$("#_sysStatus>ul").on("click", "li", function () {
				$(this).addClass("add_blue").siblings().removeClass("add_blue");
				self.LoadData();//获取数据列表
			});			
			//列表的勾选框
			$("#stock_body").on("click",".check_list_box",function(){
				$(this).children("span").toggleClass("selected");
			});
			//排序方式
            $("#product_table_fixed th").on("click", function () {
				sortFun($(this));
            });
            //复核流水
			$("#product_table").on("click",".review_btn",function(){
				myApp.popup("#review_box");
				var id=$(this).attr("value");
				$("#form_id").val(id);
			});
			 setTimeout(function () { 
		        AccountLoad();//账户下拉 12-21
		    },2000);//2s
			setTimeout(function () { 
		    	CustomersLoad();//客户下拉 10-28
			},1500);//1.5s 
		    setTimeout(function () { 
		        FlowNumber();//流水统计
		    },500);//0.5s 
			//添加输入验证 12-8 class=_add
            var validate = $("._add").validate({
                debug: true, //调试模式取消submit的默认提交功能   
                focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
                onkeyup: false,
                errorPlacement : function(error, element) { 
                    if (element.is(":radio")) 
                        error.appendTo(element.parent().parent()); 
                    else if (element.is(":checkbox")) 
                        error.appendTo(element.parent().parent()); 
                    else 
                        error.appendTo(element.parent().next()); 
                },//调radio
                submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
                    AddFlow();//添加流水
                },
                rules: {
                    Remarks: "required", 
                    Account:"required", 
                    ArrivalTime: "required", 
                    Type: "required",
                    Amount: "required",
                },
                messages: {
                    Amount:"",
                    Remarks: "",
                    Account:_("账户必选"),
                    ArrivalTime:"",
                    Type:_("收支必选"),
                }
            });
            //修改输入验证 12-8 class=_mod
            var validate = $("._mod").validate({
                debug: true, //调试模式取消submit的默认提交功能   
                focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
                onkeyup: false,
                errorPlacement : function(error, element) { 
                    if (element.is(":radio")) 
                        error.appendTo(element.parent()); 
                    else if (element.is(":checkbox")) 
                        error.appendTo(element.parent().parent()); 
                    else 
                        error.appendTo(element.parent().next()); 
                },//调radio
                submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
                    self.EditFlow();//修改流水
                },
                rules: {
                    Amount: "required",
                    Remarks: "required", 
                    Comments: "required",//审核备注
                    Account:"required", 
                    ArrivalTime: "required", 
                    Type: "required",
                    Status: "required",
                },
                messages: {
                    Amount:"",
                    Remarks: "",
                    Comments: "",//审核备注
                    Account:_("必选"),
                    ArrivalTime:"",
                    Type:_("必选"),
                    Status:_("必选"),
                }
            });

			//复核输入验证
	        var validate = $("#_review").validate({
	            debug: true, //调试模式取消submit的默认提交功能   
	            focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
	            onkeyup: false,
	            submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form   
	                self.reviewFlow();//修改流水
	            },
	            rules: {
	                Comments: "required",
	            },
	            messages: {
	                Comments:"",
	            }
	        });	
		},
		//获取参数
        getParamer:function(){
            var requestFlows = {};

            if(RoleID == 1 || RoleID == 2){                
                requestFlows.UserRealName= $.trim($("#_saleRealName").val());
            }else{
                requestFlows.ApplyID = UserID;//申请人ID
            }
            
            requestFlows.Others = $.trim($("#sel_others").val());//人物 12-30

            requestFlows.CustomerNickName = $.trim($("#_customerCs").val());//昵称


            requestFlows.CustomerRealName = $.trim($("#_customerRealName").val());

            requestFlows.Amount = $("#_amt").val();//12-21

            //账户页面传来的 _bankid
            if ($.cookie("_bankid")) {
                $("#sel_accountID").val($.cookie("_bankid"));//账户ID
                $.cookie("_bankid", "", -1);
            }
            requestFlows.Account = $("#sel_accountID").val();//账户


            requestFlows.Type = $("#sel_type").val();
            requestFlows.Abstract = $("#sel_abstract").val();//摘要 
            requestFlows.Currency = $("#sel_currency").val();//币种  
            requestFlows.Purpose = $("#sel_purpose").val();//用途
            
            requestFlows.Status = $("#_sysStatus").find(".add_blue").attr("data-value");

            requestFlows.SCreateTime = $("#screatetime").val();
            requestFlows.ECreateTime = $("#ecreatetime").val();
            requestFlows.SUpdateTime = $("#supdatetime").val();
            requestFlows.EUpdateTime = $("#eupdatetime").val();
            requestFlows.PageSize = 500; //id=_pageSizes
            requestFlows.PageIndex = 1;//.page_num是class


            return requestFlows;
        },
		 //加载
        LoadData:function(p) {
        	var self = this;
        	myApp.showIndicator();//显示加载中
            if(p){
                var requestCharges=p;
            }else{
                if(b_lang==1){
                    var requestCharges =  self.getParamer();
                    requestCharges.Status  = lang;
                }else{
                    var requestCharges = self.getParamer(requestCharges);
                }
            }
            $.ajax({
                url: "/Team/GetFlows",//提交地址
                type: "POST",//提交方式
                data: JSON.stringify(requestCharges),
                contentType: "application/json; charset=utf-8",
                success: function (result) {
                    
                    var _result = eval('(' + result + ')');//eval()解析单个json对象

		            if (_result.msgcode == false) {
		            	
		                var tr = "";//单行
		                var tds = "<td colspan='9' style='text-align:center;color:red'>" + _(_result.msginfo) + "</td>";// 多列合成一列并居中
		                tr = "<tr>" + tds + "</tr>";//将多列加到一行
		                $("#stock_body").html(tr);//加入到id为customer的table的tbody中
		                myApp.hideIndicator();  //数据加载完成后去除全屏遮罩层
		            } else {
		            	_result = _result.msginfo.Data;//object
		            	SortJson = _result;
		            	BindingData(_result, $("#stock_body"));//绑定
		            }
                    
                    myApp.hideIndicator();//隐藏加载中	
                    if(requestCharges.SysStatus==2){
                        $("#wait_user").html(_result.TotalCount);//客户总数
                    }
                }
                     
   			});
        },

        //添加流水
        AddFlow:function(){
        	var self = this;
            var requestFlow = {};
            requestFlow.Remarks = $("#remarks").val();
            //requestFlow.Comments = $("#comments").val();
            requestFlow.Others = $("#others").val();
            requestFlow.Amount = $("#amount").val();
            requestFlow.ArrivalTime = $("#arrivalTime").val();
            requestFlow.Purpose = $("#purpose option:checked").val();
            requestFlow.Currency = $("#currency option:checked").val();
            //requestFlow.Account = $("#account option:checked").val();//下拉框
            //requestFlow.Account =$('input:radio[name="Account"]:checked').val();//单选框 -静态
            requestFlow.Account =$('#_bankID1 input:radio[name="Account"]:checked').val();//单选框 -动态 12-23

            requestFlow.Status = $("#status option:checked").val();

            //requestFlow.Type = $("#type option:checked").val();//1收入 2支出
            requestFlow.Type =$('input:radio[name="Type"]:checked').val();//单选框
            requestFlow.Abstract =$('input:radio[name="Abstract"]:checked').val();//单选框

            requestFlow.ApplyID = UserID //申请人ID
            //requestFlow.ReviewID = customerId //审核人ID
                
            $.ajax({
                url: "/Team/AddFlow",//提交地址
                type: "POST",//提交方式
                data: JSON.stringify(requestFlow),
                contentType: "application/json; charset=utf-8",
                success: function (result) {
                    var _result = JSON.parse(result);
                    
                    $(".add_pop_box input[type=reset]").trigger("click");//清空form数据

                    if(_result.msgcode == true){
                        myApp.alert(_(_result.msginfo));
                        $(".add_pop_box").hide();
                        self.LoadData();//加载
                    }else{
                        myApp.alert(_result.msginfo);
                    }

                }
            });
        },
        //审核充值
        EditFlow:function() {
			var self = this;
                var requestFlow = {};

                requestFlow.ID = $("#_iD").val();
                requestFlow.OrderIDs = $("#_orderIDs").val();
                requestFlow.CustomerID = $("#_custID").val()//客户ID 
                requestFlow.Remarks = $("#_remarks").val();
                //requestFlow.Receivable = $("#_receivable").val();
                requestFlow.Comments = $("#_comments").val();//审核备注
                requestFlow.Others = $("#_others").val();
                requestFlow.Amount = $("#_amount").val();
                //requestFlow.Type = $("#_type").val();//1收入 2支出
                requestFlow.Type = $("#_type option:checked").val();//下拉框
                requestFlow.Currency = $("#_currency option:checked").val();//下拉框
                requestFlow.Abstract = $("#_abstract option:checked").val();//下拉框

                requestFlow.ArrivalTime = $("#_arrivalTime").val();

                requestFlow.Purpose = $("#_purpose option:checked").val();
                //requestFlow.Account = $("#_account option:checked").val();
                requestFlow.Account = $("#mod_accountID option:checked").val();//12-23
                
                //requestFlow.Status = $("#_status option:checked").val();//下拉框
                requestFlow.Status =$('input:radio[name="Status"]:checked').val(); //单选框

                requestFlow.ReviewID = UserID; //审核人ID 

			var msg = "";
			if($('input:radio[name="Status"]:checked').val() == 1){
				msg = _("确定“通过”？");
			}else{
				msg = _("确定“作废”？");
			}
				
			    myApp.confirm(_('请务必认真审核，一旦误操作，将导致财务出现问题。\n\n')+msg, _('审核收支'), 
			      function () {
			        $.ajax({
	                    url: "/Team/ModifyFlow",//提交地址
	                    type: "POST",//提交方式
	                    data: JSON.stringify(requestFlow),
	                    contentType: "application/json; charset=utf-8",
	                    success: function (result) {
	                        var _result = eval('(' + result + ')');//eval()解析单个json对象
	
	                        if(_result.msgcode == true){
	                            $(".modify_pop_box input[type=reset]").trigger("click");//清空form数据
	
	                            myApp.alert(_(_result.msginfo));
	                            $(".modify_pop_box").hide();
	                            self.LoadData();//加载
	                        }else{
	                            myApp.alert(_(_result.msginfo));
	                        }
	                    }
	                });
			      }
			    );
               
          },
        
        
        //复核
        reviewFlow:function(){
        	var self=this;
        	let submitJson={};
        	submitJson.ID =$("#form_id").val();//流水id
        	submitJson.ReviewID=UserID;//审核人id
        	submitJson.Comments=$("#reviewRemarks").val();//复核备注
        	$.ajax({
                url: "/Team/ReVerify",//提交地址
                type: "POST",//提交方式
                data: JSON.stringify(submitJson),
                contentType: "application/json; charset=utf-8",
                success: function (result) {
                	let data=eval('('+result+')');
                	if(data.msgcode==true){
                		$("#review_box").hide();
                		toast(_(data.msginfo));
                		self.LoadData();//加载
                	}else{
                		myApp.alert(_(data.msginfo));
                	}
                }
          	});        	        	
        },
	}
	apply.init();
})();

//账户列表
function AccountLoad() {
    var requestAccount = {};
    requestAccount.Status = 1;//启用1
    requestAccount.Type ='2,3';
    $.ajax({
        url: "/Team/GetBankList",//提交地址
        type: "POST",//提交方式
        async: false, //异步 9-27
        data: JSON.stringify(requestAccount),
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象
            if (_result.msgcode == false) {
                var options = "";
                options += '<option value="">' + _(_result.msginfo) + '</option>';
                $("#sel_accountID").html("");//账户下拉
                $("#sel_accountID").html(options);
            } else {
                var options = "";
                options += '<option value="">'+_("账户")+'</option>';
                for (var i = 0; i < _result.length; i++) {
                    options += '<option value="' + _result[i].BankID + '"  >' + _(_result[i].BankName) + '</option>';
                }
                $("#sel_accountID").html("");//账户下拉
                $("#sel_accountID").html(options);
            }
        }
    });
}

//账户列表 
function XgAccountLoad() {
    var requestAccount = {};
    requestAccount.Status = 1;//启用1
    requestAccount.Type ='2,3';
    $.ajax({
        url: "/Team/GetBankList",//提交地址
        type: "POST",//提交方式
        async: false, //异步 9-27
        data: JSON.stringify(requestAccount),
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象
            if (_result.msgcode == false) {
                var options = "";
                options += '<option value="">' + _(_result.msginfo) + '</option>';
                $("#mod_accountID").html("");//账户下拉
                $("#mod_accountID").html(options);
            } else {
                var options = "";
                options += '<option value="">'+_("账户")+'</option>';
                for (var i = 0; i < _result.length; i++) {
                    options += '<option value="' + _result[i].BankID + '"  >' + _(_result[i].BankName) + '</option>';
                }
                $("#mod_accountID").html("");//账户下拉
                $("#mod_accountID").html(options);
            }
        }
    });
}
//流水统计
function FlowNumber(){
	var self = this;
    var requestFlow = {};
	$("#_charge0").text(0);
    $("#_charge1").text(0);
    $("#_charge").text(0);
    $("#_charge2").text(0);
    $("#total_charge1").text(0);
    if(RoleID == 1 || RoleID == 2){ //管理员1 财务2
        requestFlow.UserRealName= $.trim($("#_saleRealName").val());
    }else{
        requestFlow.ApplyID = UserID;
    }

    $.ajax({
        url: "/Team/FlowNumber",//提交地址
        type: "POST",//提交方式
        data: JSON.stringify(requestFlow),
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象
            var totalcharge = 0;
            if(_result.msgcode== true){
                _result = _result.msginfo;
                for (var i = 0; i < _result.length; i++) {
                    if (_result[i].Status == 0) {
                        $("#_charge0").text(_result[i].Number);//待审0
                        totalcharge +=_result[i].Number;
                    }

                    if (_result[i].Status == 1) {
                        $("#_charge1").text(_result[i].Number);//已审1
                        totalcharge +=_result[i].Number;
                    }
					if (_result[i].Status == 2) {//已复核
                        $("#_charge2").text(_result[i].Number);
                        totalcharge +=_result[i].Number;
                    }
                    if (_result[i].Status == -1) {
                        $("#_charge").text(_result[i].Number);//已作废-1
                        totalcharge +=_result[i].Number;
                    }
                    $("#total_charge1").text(totalcharge);
                }

            }else{
                $("#_charge0").text(0);
                $("#_charge1").text(0);
                $("#_charge").text(0);
                $("#_charge2").text(0);
                $("#total_charge1").text(0);
            }
        }
    });
}
//客户昵称 
function CustomersLoad() {
    var requestCustomer={};

    //业务员3 采购员4 物流员 5
    if(RoleID == 3 || RoleID == 4 || RoleID == 5)
    {
        requestCustomer.SalesUserID = UserID;
    }

    requestCustomer.SysStatus = 1;//正常的客户 9-29

    $.ajax({
        url: "/Team/GetCustomerList",//提交地址
        type: "POST",//提交方式
        async: false, //异步 9-27
        data: JSON.stringify(requestCustomer),
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象

            if(_result.msgcode == false){

                var options = "";
                options += '<option value="">' + _(_result.msginfo) + '</option>';
                $("#_customerCodes").html("");//客户昵称下拉
                $("#_customerCodes").html(options); 

            }else{

                var options = "";
                options += '<option value="">'+_("客户昵称")+'</option>';
                for (var i = 0; i < _result.length; i++) {
                    //options += '<option value="' + _result[i].NickName + '"  >' + _result[i].NickName + '</option>';
                    options += '<option value="' +  $.trim(_result[i].NickName )+ '"  >' +$.trim( _result[i].NickName) + '</option>';//解决因为空格导致供应商无法搜索 10-27                      
                }

                $("#_customerCodes").html("");//客户昵称搜索下拉
                $("#_customerCodes").html(options);
            }
        }
    });
}


//订单详情弹出框
function detail_box(me){
    myApp.showIndicator();
    myApp.popup(".detail_pop_box");
    $.ajax({
        url: "/Team/GetOrderIDsDetail",//提交地址
        type: "POST",//提交方式
        data: "{'OrderIDs':'" + me.getAttribute("value") + "'}",
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            BindingDetail(result, $("#detail tbody"));//绑定订单详情 12-8
            myApp.hideIndicator();
        }
    });
}

//审核充值弹出框
function modify_box(me) {
    ModAccountLoad();//12-23
	myApp.popup(".edit_box");
    $.ajax({
        url: "/Team/GetFlow",//提交地址
        type: "POST",//提交方式
        data: "{'ID':'" + me.getAttribute("value") + "'}",
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象

            $("#_iD").val(_result.ID);
            $("#_orderIDs").val(_result.OrderIDs);//订单IDs
            $("#_custID").val(_result.CustomerID);//客户ID                    
             $("#_remarks").val(_result.Remarks);
             $("#_comments").val(_result.Comments);
             $("#_others").val(_result.Others);
             $("#_arrivalTime").val(DateTimeFormat(_result.ArrivalTime));                     
             $("#_amount").val(_result.Amount);
             //$("#_type").val(_result.Type); //1收入+ 2支出-
             $("#_type [value='" + _result.Type + "']").prop("selected", true);//下拉框
             $("#_abstract [value='" + _result.Abstract + "']").prop("selected", true);//下拉框
             $("#_currency [value='" + _result.Currency + "']").prop("selected", true);//下拉框

             $("#_receivable").val(_result.Receivable);//应收
             if(_result.Receivable - _result.Amount > 0){
                 $("#_bal").val(_result.Receivable - _result.Amount);//差额 = 应收 - 实收 12-6
             }else{
                 $("#_bal").val(0);//差额 = 0
             }
             $("#_purpose [value='" + _result.Purpose + "']").prop("selected", true);//下拉框
             //$("#_account [value='" + _result.Account + "']").prop("selected", true); 
             $("#mod_accountID [value='" + _result.Account + "']").prop("selected", true);//12-23 

             //$("#_status [value='" + _result.Status + "']").prop("selected", true);                    
             //$("input[name='Status'][value='" + _result.Status + "']").attr("checked",true); //给Radio赋值

        }
    });
}       
       
//计算差额
function Compute(){
    var _re =$("#_receivable").val();//应收 
    var _am =$("#_amount").val();//交易金额
    
    if(_re != ""){
        if(_re - _am > 0){

            $("#_bal").val(_re - _am); //差额 = 应收 - 实收
        }else{
            $("#_bal").val(0); //差额 = 0
        }
    }
}
//绑定订单详情
function BindingDetail(Datas, tableTbody){
    var _result = eval('(' + Datas + ')');//eval()解析单个json对象
    if(_result.msgcode == false){
        var tr = "";//单行
        var tds = "<td colspan='9' style='text-align:center;color:red'>" + _(_result.msginfo) + "</td>";// 多列合成一列并居中
        tr = "<tr>" + tds + "</tr>";//将多列加到一行
        tableTbody.html(tr);//加入到id为detail的table的tbody中
    }else{
        var _totalPrice = 0;
        var trs = "";//多行数据        
        for (var i = 0; i < _result.length; i++) {			
            var tds = "";//多列
            var tr = "";//单行
            var tr_div = "";
			let data=_result[i];
            tds += "<td>" + (i + 1) + "</td>";
            tds += "<td>" + GetText("stocks",data.IsFancy,data.Shape,"Shape") + "</td>";
            tds += "<td>" + data.Weight + "</td>";
            tds += "<td>" + CertTypeFormat(data) + "</td>";//data.CertType
            tds += "<td style='font-weight:bold;'>" + Math.round(data.ConfirmPrice) + "</td>";
            _totalPrice+=data.ConfirmPrice;
            tds += "<td style='font-weight:bold;'>" + Math.round(data.PriceUSD) + "</td>";
            tds += "<td>" + DateTimeFormat(data.CreateTime) + "</td>";
            tds += "<td style='font-weight:bold;'>" + PaymentStatusFormat(data.PaymentStatus) + "</td>";//支付状态
            tds += "<td>" + data.SalesUserName + "</td>";
            tr += "<tr class='data_tr'>" + tds + "</tr>";//将多列加到一行
            tr_div="<tr class='stock_detail'><td  colspan='9'>"+
            "<div class='detail_left' style='width:50%;'>"+
                "<i><b>"+_("颜色")+"：</b>"+data.Color+"</i>"+   //颜色 ColorFormat(data)
                "<i><b>"+_("净度")+"：</b>" + data.Clarity + "</i>"+
                "<i><b>"+_("切工")+"：</b>" +  data.Cut + "</i>"+
                "<i><b>"+_("抛光")+"：</b>" +  data.Polish + "</i>"+
                "<i><b>"+_("对称")+"：</b>" +  data.Symmetry + "</i>"+
                "<i><b>"+_("荧光")+"：</b>" +   data.Fluorescence + "</i>"+
            "</div>" +
            "<div class='detail_middle' style='width:50%;'>"+                    	
            	"<i><b>"+_("证书号")+"：</b>" + CertNoFormat(data.CertNo) + "</i>" +
            	"<i><b>"+_("退点")+"：</b>" + ConfirmdiscountFormat(data.Confirmdiscount) + "</i>"+ 
            	"<i><b>"+_("买")+"USD：</b>" + formatUSDPrice(data.PriceUSD) + "</i>"+
                "<i><b>"+_("买")+"RMB：</b>" + formatRMBPrice(data.PurchaseRMB)  + "</i>"+
                "<i><b>"+_("供应商")+"：</b>" +  data.SupplierCode + "</i>"+
                "<i><b>"+_("采购")+"：</b>" +   data.PurchaseUserName + "</i>"+
            "</div></td></tr>";
            trs += tr+tr_div;//将单行加到多行              
        }
        tableTbody.html(trs);//加入到id为detail的table的tbody中
    }
}
        
//-支出弹出框
function add_box() {
    //管理员1 财务2
    if(RoleID == 1 || RoleID == 2){
        TjAccountLoad();//12-23
		myApp.popup(".add_pop_box");
    }else{
        myApp.alert(_("禁用"));
    }
} 
 //添加流水账户列表 
function TjAccountLoad() {
    var requestAccount = {};
    requestAccount.Status = 1;//启用1
    requestAccount.Type ='2,3';
    $.ajax({
        url: "/Team/GetBankList",//提交地址
        type: "POST",//提交方式
        async: false, //异步 9-27
        data: JSON.stringify(requestAccount),
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象

            if (_result.msgcode == false) {
                var options = "";
                options += '<lable>' + _(_result.msginfo) + '</label>';
                $("#_bankID1").html("");//账户下拉
                $("#_bankID1").html(options);
            } else {
                var options = "";
                for (var i = 0; i < _result.length; i++) {
                    options += '<div><input type="radio" name="Account" value="' + _result[i].BankID + '" id="czaccout' + i + '" />'+
                    '<label for="czaccout' + i + '">' + _(_result[i].BankName) + '</label></div>';
                }
                $("#_bankID1").html("");//账户下拉
                $("#_bankID1").html(options);
            }
        }
    });
}
        
//账户审核列表
function ModAccountLoad() {

    var requestAccount = {};

    requestAccount.Status = 1;//启用1
    requestAccount.Type ='2,3';

    $.ajax({
        url: "/Team/GetBankList",//提交地址
        type: "POST",//提交方式
        async: false, //异步 9-27
        data: JSON.stringify(requestAccount),
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');//eval()解析单个json对象

            if (_result.msgcode == false) {

                var options = "";
                options += '<option value="">' + _(_result.msginfo) + '</option>';
                $("#mod_accountID").html("");//账户下拉
                $("#mod_accountID").html(options);

            } else {

                var options = "";
                options += '<option value="">'+_("账户")+'</option>';
                for (var i = 0; i < _result.length; i++) {
                    options += '<option value="' + _result[i].BankID + '"  >' + _(_result[i].BankName) + '</option>';
                }

                $("#mod_accountID").html("");//账户下拉
                $("#mod_accountID").html(options);
            }
        }
    });
}

//绑定数据
function BindingData(_result, tableTbody) {       
    var trs = "";//多行数据
    for (var i = 0; i < _result.length; i++) {		
        var tds = "";//多列
        var tr = "";//单行
        var tr_div = "";
		var data=_result[i];
        tds += "<td class='check_rel' value='"+i+"'>"+
        "<div class='check_list_box'><span class='checkbox' name='checkbox' lang='" + data.UserID + "'></span></div>";
        tds += "<td>" + NullFormat(data.BankName) + "</td>";
        if(data.Type == 1){
            //收入1
            tds += "<td>-</td>";                    
            tds += "<td>" + data.Amount + "</td>";
        }else{
            //支出2
            tds += "<td>" + data.Amount + "</td>";                    
            tds += "<td>-</td>";
        }
        tds += "<td style='font-weight:bold;'>" + TypeFormat(data.Type) + "</td>";
        tds += "<td>" + NullFormat(data.NickName) + "</td>";
        tds += "<td>" + AccountStatusFormat(data.Status) + "</td>";
        tds += "<td><span title='订单详情' onclick='detail_box(this)' value='" + data.OrderIDs + "'>"+ OrderIDsFormat(data.OrderIDs) +"</span></td>"
        //状态Status 0待审核 1已审核 -1 已作废
        if(data.Status == 0){
            tds += "<td class='check_toolbtn'><span class='modify'onclick='modify_box(this)' value='" + data.ID + "'>"+_("审核")+"</span></td>";
        }else if(data.Status == 1){
            tds += "<td class='check_toolbtn'><span class='modify review_btn' value='" + data.ID + "'>"+_("复核")+"</span></td>";          
        }
        else{
            tds += "<td class='check_toolbtn'></td>";
        }          
        
        tr += "<tr class='data_tr'>" + tds + "</tr>";//将多列加到一行
        tr_div="<tr class='stock_detail'><td  colspan='9'>"+
        "<div class='detail_left' style='width:50%;'>"+
        	"<i><b>"+_("币种")+"：</b>"+ CurrencyFormat(data.Currency) +"</i>"+
        	"<i><b>"+_("结余")+"：</b>"+ formatRMBPrice(data.Balance) +"</i>"+
            "<i><b>"+_("到账时间")+"：</b>"+DateFormat(data.ArrivalTime)+"</i>"+
            "<i><b>"+_("应支/收")+"：</b>" + formatRMBPrice(data.Receivable) + "</i>"+
            "<i><b class='custrom'>"+_("摘要")+"：</b><span>" + AbstractFormat(data.Abstract) + "</span></i>"+
            "<i><b>"+_("用途")+"：</b>" +  PurposeFormat(data.Purpose) + "</i>"+
           	"<i><b>"+_("人物")+"：</b>" +  NullFormat(data.Others) + "</i>"+
        "</div>" +
        "<div class='detail_middle' style='width:50%;'>"+      
            "<i><b>"+_("申请人")+"：</b>" +  data.Applicants + "</i>"+                       
            "<i onclick='showTotalWord(this)'><b class='custrom'>"+_("申请备注")+"：</b><span>" + NullFormat(data.Remarks) + "</span></i>"+
        	"<i><b>"+_("申请时间")+"：</b>" + DateTimeFormat(data.CreateTime) + "</i>" +
        	"<i><b>"+_("审核人")+"：</b>" + NullFormat(data.Reviewer) + "</i>"+
        	"<i onclick='showTotalWord(this)'><b class='custrom'>"+_("审核备注")+"：</b><span>" + NullFormat(data.Comments) + "</span></i>" +
        	"<i><b>"+_("审核时间")+"：</b>" +  DateTimeFormat(data.UpdateTime) + "</i>"+                    	                     	                       
        "</div></td></tr>";
        trs += tr+tr_div;//将单行加到多行                       
    }
    $("#stock_body").html(trs);//加入到id为customer的table的tbody中    
}